package Day14;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MenuPanel extends JPanel implements ActionListener {
    private ATM05 atm05;
    private JButton searchBtn = new JButton(new ImageIcon("Image/buttonFind.jpg"));
    private JButton getBtn = new JButton(new ImageIcon("Image/buttonGet.jpg"));
    private JButton saveBtn = new JButton(new ImageIcon("Image/buttonSave.jpg"));
    private JButton changePwdBtn = new JButton(new ImageIcon("Image/buttonModify.jpg"));
    private JButton transferBtn = new JButton(new ImageIcon("Image/pane.jpg"));


    public MenuPanel(ATM05 atm05){
        this.atm05 = atm05;
        this.setLayout(null);
        this.setOpaque(false);

        transferBtn.setBounds(879,300,140,50);
        transferBtn.addActionListener(this);
        this.add(transferBtn);

        changePwdBtn.setBounds(879,200,140,50);
        changePwdBtn.addActionListener(this);
        this.add(changePwdBtn);

        saveBtn.setBounds(0,200,140,50);
        saveBtn.addActionListener(this);
        this.add(saveBtn);

        searchBtn.setBounds(0,400,140,50);
        searchBtn.addActionListener(this);
        this.add(searchBtn);

        getBtn.setBounds(0,300,140,50);
        getBtn.addActionListener(this);
        this.add(getBtn);



    }
    @Override
    public void actionPerformed(ActionEvent e) {
        if(e.getSource() == saveBtn){
            atm05.showPanel("save");
        }else if(e.getSource() == transferBtn){
            atm05.showPanel("transfer");
        }else if(e.getSource() == changePwdBtn){
            atm05.showPanel("changePwd");
        }else if(e.getSource() == getBtn){
            atm05.showPanel("get");
        }else if(e.getSource() == searchBtn){
            atm05.showPanel("search");
        }
    }
}
